home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / jogos / spherical / Code / Library / polygon.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-14  |  6.5 KB  |  147 lines

  1.  
  2. // Copyright (C) 2002 by Luigi Pino.  All Rights Reserved.
  3.  
  4. /***************************************************************************/
  5.  
  6. typedef struct {
  7.     color3    color;                                                                            // Color of light
  8.     float        brightness;                                                                    // Brightness of light
  9.     float        range;                                                                            // Range of influence
  10.     float3    position;                                                                        // Position
  11. }    Shadow_Box_Struct;
  12.  
  13. typedef struct {
  14.     color3    c_new;                                                                            // Updated color values
  15.     color3    c_old;                                                                            // Original color values
  16.     color3    c_lit;                                                                            // Lighted color values
  17.     float2    percent;                                                                        // Percent of texture coordinate
  18.     float3    position;                                                                        // Position
  19.     int            angle_x;                                                                        // Temp angle_x for shadow calculations
  20.     int            angle_y;                                                                        // Temp angle_y for shadow calculations
  21. } Point_Struct;
  22.  
  23. /***************************************************************************/
  24.  
  25. class Object3_Class {
  26.     public:
  27.         Object3_Class();                                                                    // Constructor
  28.         ~Object3_Class();                                                                    // Deconstructor
  29.  
  30.         void        Calculate_Light(Shadow_Box_Struct *light);
  31.         void        Calculate_Normal();
  32.         void        Color();
  33.         void        Draw();
  34.         void        Fade(float amount);
  35.         void        Finalize_Light();
  36.         float3    Get_Base();
  37.         float3    Get_Center(int index);
  38.         int            Get_Mesh(int index);
  39.         vector3    Get_Normal(int index, int normal_index);
  40.         int            Get_Plane_Collision(int index, float3 *point);
  41.         float        Get_Plane_Distance(int index, int normal_index, float3 *point);
  42.         float3    Get_Position(int index, int point_index);
  43.         int            Get_Size();
  44.         int            Get_Texture_Image();
  45.         float2    Get_Texture_Position(int index, int point_index);
  46.         void        Initialize_Light();
  47.         void        Load_Model(char *file, int image);
  48.         void        Move(float3 *vector);
  49.         bool        Oct_Tree(int index, Object3_Class *destination, float2 *high_bound, float2 *low_bound);
  50.         void        Rotate_x(float amount);
  51.         void        Rotate_y(float amount);
  52.         void        Rotate_z(float amount);
  53.         void        Set_Alpha(int index, float alpha_value);
  54.         void        Set_Base(float3 *base_point);
  55.         void        Set_Color(int index, color3 *color0, color3 *color1, color3 *color2);
  56.         void        Set_Mesh(int index, int mesh_number);
  57.         void        Set_Position(int index, float3 *point0, float3 *point1, float3 *point2);
  58.         bool        Set_Size(int size);
  59.         void        Set_Texture_Image(int image);
  60.         void        Set_Texture_Position(int index, float2 *percent0, float2 *percent1, float2 *percent2);
  61.  
  62.     private:
  63.         typedef struct {
  64.             Point_Struct    point[3];                                                    // Points
  65.             float                    alpha;                                                        // Alpha value
  66.             float3                center;                                                        // Center
  67.             int                        mesh;                                                            // To distinguish model parts
  68.             vector3                normal[4];                                                // Normal
  69.         } Polygon3_Struct;
  70.  
  71.         Polygon3_Struct    *tri;                                                            // Triangle pointer
  72.         float3                    base;                                                            // Base point of object
  73.         int                            texture_image;                                        // Texture image
  74.         int                            size;                                                            // Size of list
  75.  
  76.         void        Initialize_Polygon(int index);
  77. };
  78.  
  79. /***************************************************************************/
  80.  
  81. class Object4_Class {
  82.     public:
  83.         Object4_Class();                                                                    // Constructor
  84.         ~Object4_Class();                                                                    // Deconstructor
  85.  
  86.         void        Calculate_Light(Shadow_Box_Struct *light);
  87.         void        Calculate_Normal();
  88.         void        Color();
  89.         void        Draw();
  90.         void        Fade(float amount);
  91.         void        Finalize_Light();
  92.         float3    Get_Base();
  93.         float3    Get_Center(int index);
  94.         vector3    Get_Normal(int index, int normal_index);
  95.         int            Get_Plane_Collision(int index, float3 *point);
  96.         float        Get_Plane_Distance(int index, int normal_index, float3 *point);
  97.         float3    Get_Position(int index, int point_index);
  98.         int            Get_Size();
  99.         void        Initialize_Light();
  100.         void        Initialize_Polygon(int index);
  101.         void        Move(float3 *vector);
  102.         void        Set_Alpha(int index, float alpha_value);
  103.         void        Set_Base(float3 *base_point);
  104.         void        Set_Color(int index, float color0r, float color0g, float color0b, float color1r, float color1g,
  105.                                             float color1b, float color2r, float color2g, float color2b, float color3r, float color3g,
  106.                                             float color3b);
  107.         void        Set_Position(int index, float point0x, float point0y, float point0z, float point1x, float point1y,
  108.                                                  float point1z, float point2x, float point2y, float point2z, float point3x, float point3y,
  109.                                                  float point3z);
  110.         bool        Set_Size(int size);
  111.         void        Set_Texture_Image(int image);
  112.         void        Set_Texture_Position(int index, float percent0x, float percent0y, float percent1x, float percent1y,
  113.                                                                  float percent2x, float percent2y, float percent3x, float percent3y);
  114.  
  115.     private:
  116.         typedef struct {
  117.             Point_Struct    point[4];                                                    // Points
  118.             float                    alpha;                                                        // Alpha value
  119.             float3                center;                                                        // Center
  120.             vector3                normal[5];                                                // Normal
  121.         } Polygon4_Struct;
  122.  
  123.         Polygon4_Struct    *quad;                                                        // Quad pointer
  124.         float3                    base;                                                            // Base point of object
  125.         int                            texture_image;                                        // Texture image
  126.         int                            size;                                                            // Size of list
  127. };
  128.  
  129. /***************************************************************************/
  130.  
  131. void Quad_Color(float top_left_x, float top_left_y, float top_left_z, float top_right_x, float top_right_y, 
  132.                                 float top_right_z, float bottom_right_x, float bottom_right_y, float bottom_right_z, float bottom_left_x,
  133.                                 float bottom_left_y, float bottom_left_z, float r, float g, float b, float a);
  134.  
  135. void Quad_Texture(int image, float top_left_x, float top_left_y, float top_left_z, float top_right_x, float top_right_y,
  136.                                     float top_right_z, float bottom_right_x, float bottom_right_y, float bottom_right_z, float bottom_left_x,
  137.                                     float bottom_left_y, float bottom_left_z, float top_left_percent_x, float top_left_percent_y,
  138.                                     float top_right_percent_x, float top_right_percent_y, float bottom_right_percent_x,
  139.                                     float bottom_right_percent_y, float bottom_left_percent_x, float bottom_left_percent_y,
  140.                                     float r, float g, float b);
  141.  
  142. void Tri_Texture(int image, float top_left_x, float top_left_y, float top_left_z, float top_right_x, float top_right_y,
  143.                                  float top_right_z, float bottom_left_x, float bottom_left_y, float bottom_left_z,
  144.                                  float top_left_percent_x, float top_left_percent_y, float top_right_percent_x, float top_right_percent_y,
  145.                                  float bottom_left_percent_x, float bottom_left_percent_y, float r, float g, float b);
  146.  
  147. /***************************************************************************/